<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>Title</title>
    <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
    <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
    <script src="../../layui-v2.2.5/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../layui-v2.2.5/layui/css/layui.css" media="all">
</head>
<body>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right: 100px"  href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
<table class="layui-hide" id="test"></table>


<button class="layui-btn" onclick="addRefundRule()">添加规则</button>
<input type="hidden" id="orgId" name="orgId" value="${orgId}">
<table class="layui-table" lay-data="{width: 1540, height:600, url:'/group/groupRefundSettingData?activityId=${activityId}&orgId=${orgId}', page:true, id:'idTest'}"
       lay-filter="demo">
    <thead>
    <tr>
        <th lay-data="{field:'id', width:80,  fixed: true}">ID</th>
        <th lay-data="{field:'personNumber', width:120, }">团人数</th>
        <th lay-data="{field:'money', width:120, }">退款金额</th>
        <th lay-data="{field:'createTime', width:200}">创建时间</th>
        <th lay-data="{fixed: 'right', width:225, align:'center', toolbar: '#barDemo'}">操作</th>
    </tr>
    </thead>
</table>

<script type="text/html" id="barDemo">
    <%--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>--%>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>



<script>
    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj);
        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    $.ajax({
                        url:'/group/delGroupRundRule',
                        type:'POST', //GET
                        async:true,    //或false,是否异步
                        data:{
                            id:data.id
                        },
                        timeout:5000,    //超时时间
                        dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                        beforeSend:function(xhr){
                            /*console.log(xhr)
                             console.log('发送前')*/
                        },
                        success:function(data){
                            if (data.code=='000000'){
                                obj.del();
                                layer.close(index);
                            }else {
                                layer.msg(data.msg);
                            }
                        },
                        error:function(xhr,textStatus){
                            console.log('错误')
                            console.log(xhr)
                            console.log(textStatus)
                        },
                        complete:function(){

                        }
                    })

                });
            } else if(obj.event === 'edit'){//
                //layer.alert('编辑行：<br>'+ JSON.stringify(data));
                layer.open({
                    type: 2,
                    title:"退款规则",
                    shadeClose:true,
                    area: ['90%', '90%'],
                    content: '/group/groupRefundSettingInfo?orgId=${orgId}&activityId=${activityId}&id='+data.id,
                    end:function () {
                        window.location.reload();
                    }
                });
            }
        });

    });

function addRefundRule() {
    layer.open({
        type: 2,
        title:"退款规则",
        shadeClose:true,
        area: ['90%', '90%'],
        content: '/group/groupRefundSettingInfo?orgId=${orgId}&activityId=${activityId}',
        end:function () {
            window.location.reload();
        }
    });
}

</script>





</body>
</html>
